﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using Student.Api.Attributes;
using Student.BLL;
using Student.ViewModel;
using Student.ViewModel.Enum;
using Student.Common;

namespace WebApplication1.Controllers
{
    [Route("[controller]/[action]")]  //将原来的"api/[controller]"修改
    [ApiController]
    public class UserController : Controller
    {
        [HttpGet]
        public IActionResult Register(string name, string pass)
        {
            var result = new UserBO().Register(name, pass);
            return Json(result);
        }

        [HttpGet]
        public IActionResult Login(string name, string pass)
        {
            var result = new UserBO().Login(name, pass);
            return Json(result);
        }

        [HttpPost]
        [ValidToken]
        public IActionResult GetList(string token, [FromBody] JObject obje)
        {

            dynamic data = obje;
            var result = new UserBO().GetList(data);
            return Json(result);
        }
    }
}
